<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/views/shared/taglib.jsp"%>

<%
	request.setAttribute("bodyAttr", "class='login-container'");
%>
<%@ include file="/WEB-INF/views/shared/base/master/limitless/default/demo/contentHeader.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/css/limitless/default/animate.jsp"%>

  <script type="text/javascript">  
	//var xmlhttp;
  function saveData(){
		if (!$("form:first").valid()){
			return;
		}
		$("form:first").submit();
	}	
	
  $(function(){
		
	});
  
  function initform(){
	//第一个文本框获取焦点
	//document.getElementById("username").focus();
	/* //产生验证码
	getCode(); */
	}
	/* //产生验证码
	function getCode(){
	var code = String(Math.round(Math.random()*10000));
	while(code.length<4){
	code = "0"+code;
	}
	document.getElementById("newcode").value=code;
	} */
	//剔除空格
	function trim(){
	return this.replace(/(^s*)|(s*$)/g, "");
	}
	//显示错误提示
	function showWarn(uid,msg){
	document.getElementById(uid).innerHTML=msg;
	document.getElementById(uid).style.display="";
	}
	//清空错误提示
	function clearWarn(uid){
	document.getElementById(uid).style.display="none";
	}
	/* //检验验证码
	function checkCode(code,uid){
	var checkcode = document.getElementById("newcode").value;
	if(checkcode==code){
	var msg="<font color='#0F0'>√√√√√</font>";
	shouWarn(uid,msg)
	return (true);
	}else{
	msg="<font color='#F00'>验证码输入错误！</font>";
	shouWarn(uid,msg);
	return (false);
	}
	} */
	
	
	//验证用户名
		function checkEmployeeAccount(employeeAccount,uid){
			var eAccount = employeeAccount.trim();
			var reg1 = /^[a-zA-Z]{1}[a-zA-Z0-9]{5,19}$/;
				if(eAccount==""){
					var msg="<font color='#F00'>账户名不可为空</font>";
					showWarn(uid,msg);
					return (false);
				}else{
					/* alert("2222");
					$.ajax({url:"/admin/register/registerInf",
							type:"post", 
							date:{eAccount:eAccount},
							success:function(){
						var result=$.getText(url);
						alert(result);
						alert("111"); */
						/* if(result=="true"){
							msg="<font color='#0F0'>账户已存在</font>";
							showWarn(uid,msg);
							return (false);
						}else  */if(reg1.test(eAccount)==true){
							msg="<font color='#0F0'>账户名可用</font>";
							showWarn(uid,msg);
							return (true);
						}else{
							msg="<font color='#F00'>账户名输入不规范！</font>";
							showWarn(uid,msg);
							return (false);
						}
					} //})
							
				}	
		//	}
	
/* 	function callback(){
		if(xmlHttp.readyState == 4){
			if(xmlHttp.status == 200){
				if(xmlHttp.responseText == "true"){
					//alert(xmlHttp.responseText);
					var msg="<font color='#F00'>账户已存在</font>";
					showWarn(uid,msg);
					return false;
				}
			}else{
				alert("请求失败");
			}
		}
	} */
 	//验证密码
	function checkEmployeePass(employeePass,uid){
 		//alert(employeePass+"2");
 		var ePass=document.getElementById("employeePass").value;
 	//	alert(a+"3");
	//var ePass = employeePass.trim();
	//alert(ePass+"1");
	var reg2 = /^[a-zA-Z0-9]{6,20}$/;
	
	if(ePass==""){
		var msg="<font color='#F00'>密码不可为空</font>";
		showWarn(uid,msg);
		return (false);
	}else if(reg2.test(ePass)==true){
		var msg="<font color='#0F0'>密码可用</font>";
		showWarn(uid,msg);
		return (true);
		}else{
			msg="<font color='#F00'>密码输入不规范！</font>";
			showWarn(uid,msg);
			return (false);
		}
 	}
 	//验证确认密码
	function checkReEmployeePass(employeePass,uid){
		var pwd = document.getElementById("reEmployeePass").value;
		var repassword = document.getElementById("employeePass").value;
	if(pwd == ""){
		var msg="<font color='#F00'>确认密码不可为空</font>";
		showWarn(uid,msg);
		return (false);
	}else if(repassword==pwd){
	var msg="<font color='#0F0'>确认密码成功</font>";
	showWarn(uid,msg);
	return (true);
	}else{
	msg="<font color='#F00'>密码与上次输入不一致！</font>";
	showWarn(uid,msg);
	return (false);
	}
	} 

 	//验证邮箱
	function checkEmail(email,uid){
	var em = email.trim();
	var reg3 = /^[a-zA-Z0-9_-]{5,}@([a-zA-Z0-9_-]{2,})+.+(com|gov|net|com.cn|edu.cn)$/;
	if(em == ""){
		var msg="<font color='#F00'>邮箱不可为空</font>";
		showWarn(uid,msg);
		return (false);	
	}else if(reg3.test(em)==true){
	var msg="<font color='#0F0'>√</font>";
	showWarn(uid,msg);
	return (true);
	}else{
	msg="<font color='#F00'>邮箱地址输入不规范！</font>";
	showWarn(uid,msg);
	return (false);
	}
	} 
 	
 	function checkMobile(mobile,uid){
 		var phone = document.getElementById("mobile").value.trim();
 		var reg4 = /^1[0-9]{10}$/;
 		if(phone=="" ){
 			var msg="<font color='#F00'>电话不可为空</font>";
 			showWarn(uid,msg);
 			return (false);
 		}else if(reg4.test(phone)==true){
 			var msg="<font color='#0F0'>本号码可用</font>";
 			showWarn(uid,msg);
 			return (true);
 		}else{
 			msg="<font color='#F00'>号码不存在！</font>";
 			showWarn(uid,msg);
 			return (false);
 		}
 	}
	/* //判断是否选择性别
	function checkSex(form,uid){
	if(form.chk_sex[0].checked||form.chk_sex[1].checked){
	clearWarn(uid);
	return(true);
	}else{
	msg="<font color='#F00'>请选择性别！</font>";
	shouWarn(uid,msg);
	return(false);
	}
	} */

	//判断表单参数
	function checkInput(){
	var form = document.employeeRegister;
	/* if(window.XMLHttpRequest){
		xmlhttp = new XMLHttpRequest();
	}else{
		xmlhttp = new ActiveXObject("Miscrosoft.XMLHTTP");
		
	}
	var eAccount = employeeAccount.trim();
	xmlhttp.onreadystatechange = checkEmployeeAccount;
	xmlhttp.open("post","/admin/register/registerInf?employeeAccount="+employeeAccount,true);
	xmlhttp.send(); */
	if(checkEmployeeAccount(form.employeeAccount.value,"employeeName_warn")&&checkEmployeePass(form.employeePass.value,"pwd_warn")&&checkReEmployeePass(form.reEmployeePass.value,"repwd_warn")&&checkEmail(form.email.value,"email_warn")&&checkMobile(form.mobile.value,"mobile_warn")){
	//alert("恭喜，注册成功！");	
	return true;
	}else{
		alert("注册失败，请按提示输入信息！");
		return false;
	}
	}

  </script> 

	<!-- Page container -->
	<div class="page-container">

		<!-- Page content -->
		<div class="page-content">

			<!-- Main content -->
			<div class="content-wrapper">

				<!-- Content area -->
				<div class="content">

					<!-- Advanced login -->
					<t:form onsubmit="return checkInput()" name="employeeRegister" commandName="employee" action="/admin/register/registerInf"  method="post">
						<div class="panel panel-body login-form">
							<div class="text-center">
								<div class="icon-object border-success text-success"><i class="icon-plus3"></i></div>
								<h5 class="content-group">注册 </h5>
							</div>

							<t:formgroup>
							<div class="form-group has-feedback has-feedback-left">
								<t:input   path="employeeName" type="text" class="form-control"  placeholder="真实姓名(必填项)"></t:input>
								<div class="form-control-feedback">
									<i class="icon-user-check text-muted"></i>
								</div>
							</div>
							
							</t:formgroup>
						
							<t:formgroup>
							<div class="form-group has-feedback has-feedback-left">
								<t:input onblur="checkEmployeeAccount(employeeAccount.value,'employeeName_warn')" onfocus="clearWarn('employeeName_warn')" path="employeeAccount" id="employeeAccount" type="text" class="form-control"  placeholder="账户名(必填项)"></t:input>
								<div class="form-control-feedback">
									<i class="icon-user-check text-muted"></i>
								</div>
								<div class="col-sm-2">
                					<span id="repasswordInfo"></span>
            					</div>
							</div>
							<div id="employeeName_warn"><font color="#666666">不少于6位不超过20位(以字母开头，数字、字母和下划线组成)</font></div>
							
							</t:formgroup>
							
 							<t:formgroup>
							<div class="form-group has-feedback has-feedback-left">
								<t:input onblur="checkEmployeePass(employeePass.value,'pwd_warn')" onfocus="clearWarn('pwd_warn')"  path="employeePass" type="password" id="employeePass" class="form-control"  value="" placeholder="密码(必填项)"></t:input>
								<div class="form-control-feedback">
									<i class="icon-user-check text-muted"></i>
								</div>
								<div class="col-sm-2">
                					<span id="passwordInfo"></span>
            					</div>
							</div>
							<div id="pwd_warn"><font color="#666666">不少于6位不超过20(由数字、字母组成，字母区分大小写)</font></div>
							</t:formgroup>
							
							<t:formgroup>
							<div class="form-group has-feedback has-feedback-left">
								<input onblur="checkReEmployeePass(reEmployeePass.value,'repwd_warn')" onfocus="clearWarn('repwd_warn')"   type="password" id="reEmployeePass" class="form-control"  placeholder="确认密码(必填项)"></input>
								<div class="form-control-feedback">
									<i class="icon-user-check text-muted"></i>
								</div>
								<div class="col-sm-2">
                					<span id="repasswordInfo"></span>
            					</div>
							</div>
							<div id="repwd_warn"><font color="#666666">请与上次输入的密码保持一致</font></div>
							</t:formgroup>
							
							
							<t:formgroup>
							<div class="form-group has-feedback has-feedback-left">
								<t:input path="email" type="text" class="form-control" onblur="checkEmail(email.value,'email_warn')" onfocus="clearWarn('email_warn')"  id="email" placeholder="邮箱(必填项)"></t:input>
								<div class="form-control-feedback">
									<i class="icon-user-check text-muted"></i>
								</div>
								<div class="col-sm-2">
                					<span id="repasswordInfo"></span>
            					</div>
							</div>
							
							<div id="email_warn"><font color="#666666">请输入有效邮件地址</font></div>
							</t:formgroup>
							
							<t:formgroup>
							<div class="form-group has-feedback has-feedback-left">
								<t:input onblur="checkMobile(mobile.value,'mobile_warn')" onfocus="clearWarn('mobile_warn')" path="mobile" type="text" class="form-control"  id="mobile" placeholder="电话(必填项)"></t:input>
								<div class="form-control-feedback">
									<i class="icon-user-check text-muted"></i>
								</div>
								<div class="col-sm-2">
                					<span id="repasswordInfo"></span>
            					</div>
							</div>
							<div id="mobile_warn"><font color="#666666">请输入有效电话号码</font></div>
							</t:formgroup>

							<button type="submit"  class="btn bg-pink-400 btn-block btn-lg">注册 <i class="icon-circle-right2 position-right"></i></button>
						</div>
					</t:form>
					<!-- /advanced login -->


				</div>
				<!-- /content area -->

			</div>
			<!-- /main content -->

		</div>
		<!-- /page content -->

	</div>

<!-- /page container -->
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formstyling.jsp"%>
<%@ include file="/WEB-INF/views/shared/scripts/topwindow.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/pages/loginRegist/login.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/notifications.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formbuttons.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/master/limitless/default/demo/contentFooter.jsp"%>
